package com.bos.data.repositories.jpa;

import com.bos.data.model.ProjectItemHistoryModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * create by luojie 2018/6/7
 */
public interface ProjectItemHistoryJPARepository extends JpaRepository<ProjectItemHistoryModel, Integer>, JpaSpecificationExecutor<ProjectItemHistoryModel> {
    @Query("select a from ProjectItemHistoryModel a where a.proid=?1  order by a.historyPid desc")
    List<ProjectItemHistoryModel> findByProid(int pid);

    @Modifying
    @Query("delete from ProjectItemHistoryModel where proitid=?1")
    int delHistoryByProitid(int id);

    @Modifying
    @Query("update ProjectItemHistoryModel a set a.value=?2 where a.id=?1")
    int updProItemHistory(int id,String value);
}
